package tk.mynoteapp.dev.demo08.equalitymethod;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("intandstringequal")
public class EqualityMethodController {
    private Logger logger = LoggerFactory.getLogger(EqualityMethodController.class);

    @GetMapping("wrong")
    public void wrong() {
        Point p1 = new Point(1, 2, "a");
        Point p2 = new Point(1, 2, "b");
        Point p3 = new Point(1, 2, "c");
        logger.info("p1.equals(p2) ? {}", p1.equals(p2));
        logger.info("p1.equals(p3) ? {}", p1.equals(p3));
    }

    class Point {
        private int x;
        private int y;
        private final String desc;

        public Point(int x, int y, String desc) {
            this.x = x;
            this.y = y;
            this.desc = desc;
        }
    }
}
